N = 10
A = zeros(N,N)
for i in 1:N, j in 1:N
abs(i-j)<=1 && A[i,j]+=1
i==j && A[i,j]-=3
end
A
10×10 Array{Float64,2}:
-2.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
1.0 -2.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 1.0 -2.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 1.0 -2.0 1.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 1.0 -2.0 1.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 1.0 -2.0 1.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 1.0 -2.0 1.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 1.0 -2.0 1.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 -2.0 1.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.0 -2.0
#### Prepare Data
X = rand(1000, 3) # feature matrix
a0 = rand(3) # ground truths
y = X * a0 + 0.1 * randn(1000); # generate response
X2 = hcat(X,ones(1000))
println(X2\y)
using MultivariateStats
println(llsq(X,y))
using DataFrames, GLM
data = DataFrame(X1=X[:,1], X2=X[:,2], X3=X[:,3],Y=y)
OLS = lm(@formula(Y ~ X1 + X2 + X3), data)
X = rand(100);
y = 2X + 0.1 * randn(100);
using Plots
b = X\y
println(b)
plotly()
scatter(X,y)
Plots.abline!(b[1],0.0, lw=3) # Slope,Intercept
[0.774894,0.988168,0.672201,-0.00991868] [0.774894,0.988168,0.672201,-0.00991868]
[1.98534]
WARNING: Method definition describe(AbstractArray) in module StatsBase at /home/crackauc/.julia/v0.5/StatsBase/src/scalarstats.jl:573 overwritten in module DataFrames at /home/crackauc/.julia/v0.5/DataFrames/src/abstractdataframe/abstractdataframe.jl:407.
r = 2.9:.001:4; numAttract = 100
steady = ones(length(r),1)*.25
for i=1:400 ## Get to steady state
steady .= r.*steady.*(1-steady)
end
x = zeros(length(steady),numAttract)
x[:,1] = steady
@inbounds for i=2:numAttract ## Grab values at the attractor
x[:,i] = r.*x[:,i-1].*(1-x[:,i-1])
end
using Plots; gr()
plot(collect(r),x,seriestype=:scatter,markersize=.002,legend=false,color=:black)